package ynu.edu;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@SpringBootApplication
@EnableDiscoveryClient
@RestController
public class Provider2Application11002 {

    private final String port= "11002";

    // GET方法
    @GetMapping("/data/{id}")
    public String getData(@PathVariable("id") String id) {
        return "GET响应（端口：" + port + "），数据ID：" + id;
    }

    // POST方法
    @PostMapping("/data")
    public String createData(@RequestBody Map<String, String> request) {
        return "POST响应（端口：" + port + "），内容：" + request.get("content");
    }

    // PUT方法
    @PutMapping("/data/{id}")
    public String updateData(@PathVariable("id") String id, @RequestBody Map<String, String> request) {
        return "PUT响应（端口：" + port + "），更新ID：" + id + "，新内容：" + request.get("content");
    }

    // DELETE方法
    @DeleteMapping("/data/{id}")
    public String deleteData(@PathVariable("id") String id) {
        return "DELETE响应（端口：" + port + "），删除ID：" + id;
    }

    public static void main(String[] args) {SpringApplication.run(Provider2Application11002.class, args);}
}